var Q = require('q'),
    entityCollection = require('../../../Base/server/controllers/EntityCollection');

// 获取所有有效工位
exports.getStation = function(req, res) {
    var deferred = Q.defer();

    var entity = entityCollection.getEntity("WorkLocation");
    entity.Entity
    .find({IsEffective: true}, { Code: 1, Name: 1})
    .exec(function (err, records) {
        if (err) {
            var newErr = new Error();
            newErr.leval = 9;
            newErr.title = '查询工位错误';
            newErr.message = '获取所有有效工位失败！';
            deferred.reject(newErr);
            return;
        }
        deferred.resolve(records);
    });

    return deferred.promise;
};